﻿using System;

namespace Avin.Infrastructure.Entity
{
    public class EntityBase<Key> where Key : struct
    {
        public virtual Key Id { get; set; }
    }

    public interface ICreateEntity
    {
        DateTime CreateTime { get; set; }

        Guid CreateUserId { get; set; }
    }

    public interface IUpdateEntity
    {
        DateTime? ModifyTime { get; set; }

        Guid ModifyUserId { get; set; }
    }

    public interface IVersionEntity
    {
        Guid Version { get; set; }
    }

    public interface ISoftDeletedEntity
    {
        DateTime? DeleteTime { get; set; }

        Guid DeleteUserId { get; set; }

        bool IsDeleted { get; set; }
    }

    public class CreateEntity<Key> : EntityBase<Key>, ICreateEntity where Key : struct
    {
        public DateTime CreateTime { get; set; }

        public Guid CreateUserId { get; set; }
    }

    public class UpdateEntity<Key> : CreateEntity<Key>, IUpdateEntity where Key : struct
    {
        public DateTime? ModifyTime { get; set; } = null;

        public Guid ModifyUserId { get; set; }
    }

    public class UpdateEntityWithVersion<Key> : UpdateEntity<Key>, IVersionEntity where Key : struct
    {
        public Guid Version { get; set; } = Guid.NewGuid();
    }

    public class FullEntity<Key> : UpdateEntity<Key>, ISoftDeletedEntity where Key : struct
    {
        public DateTime? DeleteTime { get; set; } = null;

        public Guid DeleteUserId { get; set; }

        public bool IsDeleted { get; set; } = false;
    }
}
